home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / hsrc_117.zip / MCI.C < prev    next >
C/C++ Source or Header  |  1990-11-08  |  3KB  |  122 lines

  1. /* Message command interpreter function */
  2.  
  3. #include "msgg.h"
  4. #include "twindow.h"
  5. #include "keys.h"
  6. #include "headedit.h"
  7.  
  8.  
  9. char * pascal mci (char *text) {
  10.  
  11.     static char s[256];
  12.     char work[81];
  13.     char temp[36];
  14.     char *p;
  15.     register word x=0;
  16.     struct date dos_date;
  17.     struct time dos_time;
  18.  
  19.     if (!strlen(text)) return text;
  20.     stripcr(text);
  21.     if (!strlen(text)) return "\r\n";
  22.     *work=0;
  23.     if (*text=='^') strcat(work," ");
  24.     strcat(work,text);
  25.     text=work;
  26.     strcpy(s,strtok(text,"^"));
  27.     while ((p=strtok(0,"^"))!=NULL && (strlen(s)+strlen(p)+1)<(256-35)) {
  28.         switch ((int)toupper(*p)) {
  29.             case 'H':   if (!isdigit(p[1])) {
  30.                             strcat(s,"\b");
  31.                             p++;
  32.                             break;
  33.                         }
  34.                         for (x=0;x<(p[1]-'0');x++) strcat(s,"\b");
  35.                         p+=2;
  36.                         break;
  37.             case 'U':   strcpy(temp,name);
  38.                         if (!isdigit(p[1]) || p[1]=='0') {
  39.                             strcat(s,temp);
  40.                             if (p[1]!='0') {
  41.                                 p++;
  42.                                 break;
  43.                             }
  44.                         }
  45.                         else if (p[1]=='1' || !strchr(temp,' ')) {
  46.  
  47.                             char *pp;
  48.  
  49.                             if(pp=strchr(temp,' ')) *pp=0;
  50.                             strcat(s,temp);
  51.                         }
  52.                         else {
  53.                             strtok(temp," ");
  54.                             strcat(s,strtok(0," \n"));
  55.                         }
  56.                         p+=2;
  57.                         break;
  58.             case 'B':   if(!nobell)strcat(s,"\x7");
  59.                         p++;
  60.                         break;
  61.             case 'A':   p++;
  62.                         if(isdigit(*p)) *p=*p-'0';
  63.                         else if(toupper(*p)=='A') {
  64.                             strcat(temp,"\x1b[36m");
  65.                             goto CoitusInterruptus;
  66.                         }
  67.                         else {
  68.                             p--;
  69.                             break;
  70.                         }
  71.                         strcat(temp,"\x1b[");
  72.                         switch((int)(*p)) {
  73.                             case 0: strcat(temp,"0;1;32");
  74.                                     break;
  75.                             case 1: strcat(temp,"1");
  76.                                     break;
  77.                             case 2: strcat(temp,"2");
  78.                                     break;
  79.                             case 3: strcat(temp,"5");
  80.                                     break;
  81.                             case 4: strcat(temp,"7");
  82.                                     break;
  83.                             case 5: strcat(temp,"31");
  84.                                     break;
  85.                             case 6: strcat(temp,"32");
  86.                                     break;
  87.                             case 7: strcat(temp,"33");
  88.                                     break;
  89.                             case 8: strcat(temp,"34");
  90.                                     break;
  91.                             case 9: strcat(temp,"35");
  92.                                     break;
  93.                         }
  94.                         strcat(temp,"m");
  95. CoitusInterruptus:
  96.                         strcat(s,temp);
  97.                         p++;
  98.                         break;
  99.             case 'T':   gettime(&dos_time);
  100.                         strcat(s,saytime(&dos_time));
  101.                         p++;
  102.                         break;
  103.             case 'D':    getdate(&dos_date);
  104.                         strcat(s,saydate(&dos_date));
  105.                         p++;
  106.                         break;
  107.             case 'R':   strcat(s,"unlimited");
  108.                         p++;
  109.                         break;
  110.             case 'S':   slowprint=1;
  111.                         p++;
  112.                         break;
  113.             default:    break;
  114.         }
  115.         strcat(s,p);
  116.     }
  117.     strcat(s,"\r\n");
  118.     return s;
  119. }
  120.  
  121.  
  122.